<template>
	<view class="main">

		<u-navbar :is-back="false" :title="i18n.navbar.index" :background="background" :border-bottom="false"
			title-color="#000000" back-icon-color="#000"></u-navbar>
		<view class="all">
			<!-- 数据看板 -->
			<view class="data_kanban">
				<view class="title">
					{{i18n.index.data_kanban}}
				</view>
				<view class="data">
					<view class="data_l">
						<text class="smtitle">{{i18n.index.today_sales}}</text>
						<text class="money">¥{{data_kanban.sales}}</text>
						<text
							class="sales">{{i18n.index.yesterday_sales}}:<text>{{data_kanban.yesterdaySales}}</text>元</text>
					</view>
					<view class="xian">
					</view>
					<view class="data_l">
						<text class="smtitle">{{i18n.index.today_order}}</text>
						<text class="money">{{data_kanban.orderNum}}</text>
						<text
							class="order">{{i18n.index.yesterday_order}}:<text>{{data_kanban.yesterdayOrderNum}}</text></text>
					</view>
				</view>
			</view>
			<!-- 经营数据 -->
			<view class="management">
				<view class="title">
					经营数据
				</view>
				<view class="type">
					<view class="one_of" v-for="(item,index) in i18n.index.typelist" :key="index">
						<view class="num">
							{{item.num}}
						</view>
						<view class="state">
							{{item.title}}
						</view>
					</view>
				</view>
			</view>
			<!-- 操作 -->
			<view class="operate">
				<view class="shell" @click="router('../../users/business_info/business_info')">
					<image src="../../../static/images/set.png" mode=""></image>
					<text>{{i18n.index.merchant_set}}</text>
				</view>
				<view class="shell" @click="router('../../commoditys/commodity/commodity')">
					<image src="../../../static/images/shop.png" mode=""></image>
					<text>{{i18n.index.commodity_manage}}</text>
				</view>
				<view class="shell" @click="router('../../orders/order/order')">
					<image src="../../../static/images/order.png" mode=""></image>
					<text>{{i18n.index.order_manage}}</text>
				</view>
				<view class="shell">
					<image src="../../../static/images/yhj.png" mode=""></image>
					<text>{{i18n.index.coupon}}</text>
				</view>
				<view class="shell" @click="router('../../malls/mall/mall')">
					<image src="../../../static/images/pf.png" mode=""></image>
					<text>{{i18n.index.wholesale_market}}</text>
				</view>
			</view>
		</view>

		<!-- <u-loading :show="show" style="margin-top: 100rpx;"></u-loading> -->
	</view>
</template>
<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#fff',
				},
				data_kanban: '',
				data_manage: '',

			}
		},

		onLoad(options) {
			this.getdata()
			this.getdata2()

		},
		computed: {
			i18n() {
				return this.$t('message')
			},
		},
		onShow() {
			this.lang()
		},
		methods: {
			router(path){
				console.log(path);
				uni.switchTab({
					url:'../../users/user/user'
				})
			},
			lang() {
				this._i18n.locale = uni.getStorageSync('select')
			},
			//获取首页数据
			getdata() {
				global.$http.request({
					url: '/api/admin/merchant/statistics/home/index',
					method: 'GET',
					header: {
						'Authori-zation': uni.getStorageSync('token') //自定义请求头信息
					},
				}).then(res => {
					if (res.data.code == 200) {
						console.log(res.data.data);
						this.data_kanban = res.data.data
					}
				})
			},

			getdata2() {
				global.$http.request({
					url: '/api/admin/merchant/statistics/home/operating/data',
					method: 'GET',
					header: {
						'Authori-zation': uni.getStorageSync('token') //自定义请求头信息
					},
				}).then(res => {
					if (res.data.code == 200) {
						console.log(res.data.data);
						var a = this.i18n.index.typelist
						a[0].num = res.data.data.notShippingOrderNum
						a[1].num = res.data.data.refundingOrderNum
						a[2].num = res.data.data.vigilanceInventoryNum
						a[3].num = res.data.data.onSaleProductNum
						a[4].num = res.data.data.notSaleProductNum
						this.i18n.index.typelist = a

					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		width: 750rpx;
		height: 100%;
		background-color: #F7F7F7;

		.main {
			width: 750rpx;

			.all {

				// 数据看板
				.data_kanban {
					background-color: #fff;

					.title {
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #304156;
						padding: 22rpx 0 31rpx 20rpx;
					}

					.data {
						display: flex;
						justify-content: space-around;
						align-items: center;

						.data_l {
							display: flex;
							flex-direction: column;
							align-items: center;

							.smtitle {
								font-size: 22rpx;
								font-family: PingFang SC;
								font-weight: 400;
								color: #999999;
							}

							.money {
								font-size: 36rpx;
								font-family: Source Han Sans CN;
								font-weight: 500;
								color: #333333;
								padding: 11rpx 0 42rpx 0;
							}

							.sales {
								font-size: 22rpx;
								font-family: PingFang SC;
								font-weight: 400;
								color: #999999;
								padding-bottom: 26rpx;

								text {
									color: #FF0000;
								}
							}

							.order {
								font-size: 22rpx;
								font-family: PingFang SC;
								font-weight: 400;
								color: #999999;
								padding-bottom: 26rpx;

								text {
									color: #000000;
								}
							}
						}

						.xian {
							width: 1rpx;
							height: 126rpx;
							background: #E6E6E6;
						}

					}
				}


				// 经营数据
				.management {
					margin-top: 10rpx;
					background-color: #fff;
					padding-bottom: 35rpx;

					.title {
						padding: 21rpx 0 0rpx 20rpx;
						font-size: 28rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #304156;

					}

					.type {
						width: 750rpx;
						display: flex;
						flex-wrap: wrap;
						align-items: center;

						.one_of {
							width: 187.5rpx;
							display: flex;
							flex-direction: column;
							align-items: center;

							.num {
								padding: 34rpx 0 21rpx 0;
								font-size: 36rpx;
								font-family: Source Han Sans CN;
								font-weight: 500;
								color: #333333;
							}

							.state {
								font-size: 22rpx;
								font-family: PingFang SC;
								font-weight: 400;
								color: #999999;
								text-align: center;
							}
						}
					}
				}

				// 操作
				.operate {
					display: flex;
					flex-wrap: wrap;
					align-items: center;
					margin-top: 11rpx;

					.shell {
						padding-top: 31rpx;
						width: 187.5rpx;
						display: flex;
						flex-direction: column;
						align-items: center;

						image {
							width: 98rpx;
							height: 98rpx;
						}

						text {
							text-align: center;
							padding-top: 14rpx;
							font-size: 24rpx;
							font-family: PingFang SC;
							font-weight: 400;
							color: #333333;
						}
					}
				}
			}
		}
	}
</style>
